**THIS DOFILE PRODUCES ALL THE TABLES AND FIGURES IN THE ARTICLE "ADVANTAGE OF BACKWARDNESS? THE COERCIVE IMBALANCE OUTSIDE WESTERN EUROPE" AND ITS ONLINE APPENDIX 

*IMPORTANT: Set current directory to path of do-file before running
*cd "path of this do file"

// OUTLINE OF THIS DO-FILE
* 1 Data Preparation Described in Text
* 2 All Regression Tables in the Main Text
* 3 All Regression Tables in the Online Appendix
* 4 All Figures in the Main Text
* 5 All Figures in the Online Appendix

cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication 
use "coercive_imbalance_final/ci_main_jop.dta", clear

log using "C:\Users\ngb815\Dropbox\Coercive_tech\stata\coercive_imbalance\Replication\results_coercive_imbalance.log"


*###############################################################################
*	1 DATA PREPARATION DESCRIBED IN TEXT
*###############################################################################

*Exclude great powers (cf. Section 5.1)
drop if country=="France" | country=="Germany" | country=="Russian Federation" | country=="United Kingdom" | country=="United States" 

*Exlude country-years with less than 1 million (cf. Section 5)
drop if tpop<1000

*Data in four-year intervals (cf. Section 5)
drop if year/4!=round(year/4)
drop if year<1850 //this limits secures that we have variation in mtechiv_exf in the entire sample
sort country year
egen yearno=group(year)
xtset ccode yearno

*truncate (cf. Section 5)
replace lagwe_lngdpc=min(lagwe_lngdpc,100)  if lagwe_lngdpc!=.
replace lagwe_mtech_exf=min(lagwe_mtech_exf,100) if lagwe_mtech_exf!=.
replace lagwe_mtech_exf_iv_n2=min(lagwe_mtech_exf_iv_n2,100) if lagwe_mtech_exf_iv_n2!=.
replace lagwe_mtech_s=min(lagwe_mtech_s,100)

*generating variable to keep sample constant
gen balance=1 if L.lagwe_mtech_exf!=. & L.lagwe_mtech_exf_iv_n2!=. & L.lagwe_lngdpc!=.
label variable balance "Balance"

*###############################################################################
*	2 ALL REGRESSION TABLES IN THE MAIN TEXT
*###############################################################################

//Table 2: Arms Technology and Democracy
reghdfe v2x_polyarchy L.lagwe_mtech_exf L.lagwe_mtech_s L.lagwe_lngdpc  if balance==1, vce(cluster country) absorb(year country) 
outreg2 using "coercive_imbalance_tables/Table2.tex", keep(L.lagwe_mtech_exf L.lagwe_mtech_s L.lagwe_lngdpc) label   addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant)) replace sortvar(L.lagwe_mtech_exf L.lagwe_mtech_s  L.lagwe_lngdpc) cttop(OLS)
reghdfe v2x_polyarchy L.lagwe_mtech_exf L.lagwe_mtech_exf_weu L.lagwe_lngdpc  if balance==1, vce(cluster country) absorb(country i.weu#i.year year)
outreg2 using "coercive_imbalance_tables/Table2.tex", keep(L.lagwe_mtech_exf L.lagwe_mtech_exf_weu L.lagwe_lngdpc) label  addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_nested))  sortvar(L.lagwe_mtech_exf  L.lagwe_mtech_s L.lagwe_mtech_exf_weu L.lagwe_lngdpc) cttop(OLS) append 
reghdfe v2x_polyarchy L.lagwe_mtech_exf L.lagwe_lngdpc  if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table2.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant)) cttop(OLS) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table2.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(2SLS)   append
xtabond2 v2x_polyarchy  L.(v2x_polyarchy lagwe_mtech_exf lagwe_lngdpc) i.year if balance==1 & weu==0,  gmm(L.(v2x_polyarchy lagwe_mtech_exf lagwe_lngdpc), lag(1 2) collapse) iv(i.year) twostep robust   cluster(country)
outreg2 using "coercive_imbalance_tables/Table2.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc L.v2x_polyarchy) label addtext(Sample, Excl. WEU) bdec(2) dec(2)  nocons nor2 noni  addstat(Countries, e(N_g) ) cttop(System GMM) append


//Table 3: Arms technology and Bureaucracy. Panel A
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3a.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) groupvar("Panel_A") replace
ivreghdfe v2x_corr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3a.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  groupvar("Panel_A") append
ivreghdfe v2x_execorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3a.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  groupvar("Panel_A") append
ivreghdfe v2clrspct  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)   L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3a.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  groupvar("Panel_A") append
*Table 3: Arms technology and Bureaucracy. Panel B
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc L.democracy  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3b.tex",  keep(L.lagwe_mtech_exf) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))groupvar("Panel_B") replace
ivreghdfe v2x_corr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc L.democracy  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3b.tex",  keep(L.lagwe_mtech_exf ) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) groupvar("Panel_B") append
ivreghdfe v2x_execorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc L.democracy if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3b.tex",  keep(L.lagwe_mtech_exf ) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) groupvar("Panel_B") append
ivreghdfe v2clrspct  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)   L.lagwe_lngdpc L.democracy if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table3b.tex",  keep(L.lagwe_mtech_exf) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))groupvar("Panel_B") append

//Table 4: Robustness of 2SLS-results 
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.n1_democracy_avg L.n2_democracy_avg if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addtext(ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Spillovers)  replace  
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.n1_interstatewar L.n2_interstatewar L.n1_civilwar L.n2_civilwar  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Spillovers) append 
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.distw1_democracy L.distw1_interstatewar L.distw1_civilwar L.distw1_lngdp  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Spillovers) append  
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.interstatewar_3y L.civilwar_3y  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(War & Alliances) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.ally_USA L.ally_Russia if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(War & Alliances) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.lntrade    if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Trade & Aid) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.lnaid    if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Trade & Aid) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc    if balance==1 & weu==0, robust cluster(country) absorb(country i.year##i.colony_uk i.year##i.colony_fra i.year##i.colony_ger i.year##i.colony_ussr i.year##i.colony_rest )
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2  addtext(ColonizerxTime-FE, Yes) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries,e(df_a_nested))  cttop(Colonization) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc    if balance==1 & weu==0 & colony!=1, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table4.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  cttop(Colonization) append


//Table 5: Mechanisms 
*ivreghdfe regime_rest (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc  if balance==1 & weu==0  , robust cluster(country) absorb(country year)
*outreg2 using "coercive_imbalance_tables/Table5.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2   addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))    replace NOT INCLUDED IN REPLICATION SINCE BANKS DATA NOT PUBLICLY AVAILABLE
ivreghdfe v2csreprss (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table5.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2   addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))    replace
ivreghdfe v2clkill (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table5.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2   addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))   append
ivreghdfe lnmilper (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2)  L.lagwe_lngdpc L.lnmilex  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/Table5.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc L.lnmilex) label bdec(2) dec(2) nocons nor2   addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant) )  append


*###############################################################################
*	3 ALL REGRESSION TABLES IN THE ONLINE APPENDIX
*###############################################################################
preserve 
keep if balance==1
outreg2 using "coercive_imbalance_tables/TableA2.tex", label  replace sum(log) keep(lagwe_mtech_exf lagwe_mtech_s mtech_exf mtech_sa index_irt_exsa lagwe_mtech_s lagwe_mtech_exf_iv_n2 lagwe_mtech_exf_iv_n2 lagwe_lngdpc  lngdp  v2x_polyarchy democracy v2x_pubcorr v2x_corr v2x_execorr v2clrspct  v2csreprss v2clkill lnmilper n1_democracy_avg n2_democracy_avg n1_interstatewar n2_interstatewar n1_civilwar n2_civilwar distw1_democracy distw1_interstatewar distw1_civilwar distw1_lngdp interstatewar_3y civilwar_3y ally_USA ally_Russia lntrade lnaid lnmilex) sortvar(lagwe_mtech_exf lagwe_mtech_s mtech_exf mtech_sa index_irt_exsa lagwe_mtech_s lagwe_mtech_exf_iv_n2 lagwe_mtech_exf_iv_n2 lagwe_lngdpc  lngdp  v2x_polyarchy democracy v2x_pubcorr v2x_corr v2x_execorr v2clrspct  v2csreprss v2clkill lnmilper n1_democracy_avg n2_democracy_avg n1_interstatewar n2_interstatewar n1_civilwar n2_civilwar distw1_democracy distw1_interstatewar distw1_civilwar distw1_lngdp interstatewar_3y civilwar_3y ally_USA ally_Russia lntrade lnaid lnmilex) eqkeep(mean sd N) 
restore

//Appendix Table A3 -- First Stage Results from 2SLS-Analyses
reghdfe L.lagwe_mtech_exf L.lagwe_mtech_exf_iv_n2 L.lagwe_lngdpc  if balance==1 & weu==0 & v2x_polyarchy!=., vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA3.tex", keep(L.lagwe_mtech_exf_iv_n2) label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant)) cttop(Polyarchy)  replace
reghdfe L.lagwe_mtech_exf L.lagwe_mtech_exf_iv_n2 L.lagwe_lngdpc  if balance==1 & weu==0 & v2x_pubcorr!=., vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA3.tex",  keep(L.lagwe_mtech_exf_iv_n2) label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant)) cttop(Public Sector Corruption)  append

//Appendix Table A4 -- Alternative Instrument Construction
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA4.tex", label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Instrument excl. neighbors)  replace
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2_500) L.lagwe_lngdpc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA4.tex", label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Instrument excl. countries within 500km)  append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2_750) L.lagwe_lngdpc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA4.tex", label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Instrument excl. countries within 750km)  append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2_1000) L.lagwe_lngdpc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA4.tex", label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Instrument excl. countries within 1000km)  append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n1) L.lagwe_lngdpc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA4.tex", label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Instrument includes neighbors)  append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2_pop) L.lagwe_lngdpc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA4.tex", label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Instrument includes pop. weights)  append


//Appendix Table A5: Formative Arms Technology Index and Democracy
reghdfe v2x_polyarchy L.mtech_exf L.mtech_sa L.lngdp  if balance==1, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA5.tex", keep(L.mtech_exf L.mtech_sa L.lngdp) label   addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant))  sortvar(L.mtech_exf L.mtech_sa L.lngdp) cttop(OLS) replace
reghdfe v2x_polyarchy L.mtech_exf L.mtech_exf_weu L.lngdp  if balance==1, vce(cluster country) absorb(country i.weu#i.year year)
outreg2 using "coercive_imbalance_tables/TableA5.tex",  keep(L.mtech_exf L.mtech_exf_weu L.lngdp) label   addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_nested))  sortvar(L.mtech_exf L.mtech_sa L.mtech_exf_weu L.lngdp) cttop(OLS) append 
reghdfe v2x_polyarchy L.mtech_exf L.lngdp  if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA5.tex", keep(L.mtech_exf   L.lngdp) label   addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant))  sortvar(L.mtech_exf L.mtech_sa L.mtech_exf_weu L.lngdp) cttop(OLS) append  
ivreghdfe v2x_polyarchy  (L.mtech_exf =L.mtech_exf_iv_n2) L.lngdp  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA5.tex",  keep(L.mtech_exf L.lngdp) label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(2SLS)   append
xtabond2 v2x_polyarchy L.(mtech_exf lngdpc v2x_polyarchy) i.year if balance==1 & weu==0,  gmm(L.(v2x_polyarchy mtech_exf lngdpc), lag(1 2) collapse) iv(i.year) twostep  cluster(country)
outreg2 using "coercive_imbalance_tables/TableA5.tex", keep(L.mtech_exf L.lngdpc L.v2x_polyarchy) label addtext(Sample, Excl. WEU) bdec(2) dec(2)  nocons nor2 noni  addstat(Countries, e(N_g) ) cttop(System GMM) append



//Appendix Table A6: Arms Technology Index (IRT) and Democracy
reghdfe v2x_polyarchy L.index_irt_exsa L.index_irt_sa L.lngdpc  if balance==1, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA6.tex",  keep(L.index_irt_exsa L.index_irt_sa L.lagwe_mtech_s L.lngdpc) label   addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant))  sortvar(L.index_irt_exsa L.lagwe_mtech_s L.lngdpc) cttop(OLS) replace
reghdfe v2x_polyarchy L.index_irt_exsa L.index_irt_exsa_weu L.lngdpc  if balance==1, vce(cluster country) absorb(country i.weu#i.year year)
outreg2 using "coercive_imbalance_tables/TableA6.tex",keep(L.index_irt_exsa L.index_irt_exsa_weu L.lngdpc) label   addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_nested))  sortvar(L.index_irt_exsa L.lagwe_mtech_s L.index_irt_exsa_weu L.lngdpc) cttop(OLS) append
reghdfe v2x_polyarchy L.index_irt_exsa L.lngdpc if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA6.tex", keep(L.index_irt_exsa L.lngdpc) label   addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_nested))  sortvar(L.index_irt_exsa L.lagwe_mtech_s L.index_irt_exsa_weu L.lngdpc) cttop(OLS) append
ivreghdfe v2x_polyarchy  (L.index_irt_exsa = L.distw2_index_irt_exsa)  L.lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA6.tex", keep(L.index_irt_exsa L.lngdp) label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(2SLS)   append
xtabond2 v2x_polyarchy L.v2x_polyarchy L.(index_irt_exsa lngdpc) i.year if balance==1 & weu==0,  gmm(L.(v2x_polyarchy index_irt_exsa lngdpc), lag(1 2) collapse) iv(i.year) twostep  cluster(country)
outreg2 using "coercive_imbalance_tables/TableA6.tex",  keep(L.index_irt_exsa  L.lngdpc) label addtext(Sample, Excl. WEU) bdec(2) dec(2)  nocons nor2 noni  addstat(Countries, e(N_g) ) cttop(System GMM) append

//Appendix Table A7: Arms Technology and Democracy -- Using the BMR Indicator
replace democracy=democracy*100
reghdfe democracy L.lagwe_mtech_exf L.lagwe_mtech_s L.lagwe_lngdpc  if balance==1, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA7.tex", keep(L.lagwe_mtech_exf L.lagwe_mtech_s L.lagwe_lngdpc) label   addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries, e(df_a_redundant))  sortvar(L.lagwe_mtech_exf L.lagwe_mtech_s L.lagwe_lngdpc) cttop(OLS) replace
reghdfe democracy L.lagwe_mtech_exf L.lagwe_mtech_exf_weu L.lagwe_lngdpc  if balance==1, vce(cluster country) absorb(country i.weu#i.year year)
outreg2 using "coercive_imbalance_tables/TableA7.tex", keep(L.lagwe_mtech_exf L.lagwe_mtech_exf_weu L.lagwe_lngdpc) label   addtext(Sample, Full) bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_nested))  sortvar(L.lagwe_mtech_exf L.lagwe_mtech_s L.lagwe_mtech_exf_weu L.lagwe_lngdpc) cttop(OLS) append
reghdfe democracy L.lagwe_mtech_exf L.lagwe_lngdpc  if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA7.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label   addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_nested))  sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) cttop(OLS) append
ivreghdfe democracy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA7.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label addtext(Sample, Excl. WEU) bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(2SLS)   append
xtabond2 democracy  L.(democracy lagwe_mtech_exf lagwe_lngdpc) if balance==1 & weu==0,  gmm(L.(democracy lagwe_mtech_exf lagwe_lngdpc), lag(1 2) collapse) iv(i.year) twostep robust  cluster(country)
outreg2 using "coercive_imbalance_tables/TableA7.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label addtext(Sample, Excl. WEU) bdec(2) dec(2)  nocons nor2 noni  addstat(Countries, e(N_g) ) cttop(System GMM) append

//Appendix Table A8: Robustness of 2SLS-Results for Democracy (Identical to Table 4 above, which does not show controls)
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.n1_democracy_avg L.n2_democracy_avg if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA8.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) replace  
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.n1_interstatewar L.n2_interstatewar L.n1_civilwar L.n2_civilwar  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA8.tex",  label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc L.n1_democracy_avg L.n2_democracy_avg L.n1_interstatewar L.n2_interstatewar L.n1_civilwar L.n2_civilwar)  append 
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.distw1_democracy L.distw1_interstatewar L.distw1_civilwar L.distw1_lngdp  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA8.tex",  label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) append  
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.interstatewar_3y L.civilwar_3y  if balance==1 & weu==0, robust cluster(country) absorb(country year) 
outreg2 using "coercive_imbalance_tables/TableA8.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.ally_USA L.ally_Russia if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA8.tex",   label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.lntrade    if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA8.tex",  label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.lnaid    if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA8.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc    if balance==1 & weu==0, robust cluster(country) absorb(country i.year##i.colony_uk i.year##i.colony_fra i.year##i.colony_ger i.year##i.colony_ussr i.year##i.colony_rest )
outreg2 using "coercive_imbalance_tables/TableA8.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, Yes) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_nested))  append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc    if balance==1 & weu==0 & colony!=1, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA8.tex", keep(L.lagwe_mtech_exf L.lagwe_lngdpc) label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU & ex-colonies) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) append

*Table A.9: Excluding Regions and Time Periods
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc if balance==1 & weu==0 & region!="Sub-Saharan Africa", robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA9.tex", label bdec(2) dec(2) nocons nor2 addtext(Estimator, 2SLS) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))cttop(Excl. SSA) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) replace
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc if balance==1 & weu==0 & colony!=1, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA9.tex", label bdec(2) dec(2) nocons nor2 addtext(Estimator, 2SLS) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))cttop(Excl. excolonies) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc if balance==1 & weu==0 & region!="MENA", robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA9.tex", label bdec(2) dec(2) nocons nor2 addtext(Estimator, 2SLS) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))cttop(Excl. MENA) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc if balance==1 & weu==0 & region!="Asia and Oceania", robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA9.tex", label bdec(2) dec(2) nocons nor2 addtext(Estimator, 2SLS) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) cttop(Excl. Asia & Oceania) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
reghdfe v2x_polyarchy  L.c.lagwe_mtech_exf##c.coldwar   L.c.lagwe_lngdpc##c.coldwar if balance==1 & weu==0, vce (cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA9.tex", label bdec(2) dec(2) nocons nor2 addtext(Estimator, OLS) addstat(Countries,  e(df_a_redundant)) cttop(Cold War Interaction) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc if balance==1 & weu==0 & year<1948  | balance==1 & weu==0 &  year>1990 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA9.tex", label bdec(2) dec(2) nocons nor2 addtext(Estimator, 2SLS) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))cttop(Excl. 1948-91) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc if balance==1 & weu==0 & year<1960  | balance==1 & weu==0 &  year>1989 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA9.tex", label bdec(2) dec(2) nocons nor2 addtext(Estimator, 2SLS) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))cttop(Excl. 1960-91) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append

*Table A10: Controlling for OIL and Natural Resources
reghdfe v2x_polyarchy  L.lagwe_mtech_exf  L.lagwe_lngdpc L.le_total_oil_income_pc if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA10.tex", label bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_redundant)) cttop(OLS) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) replace
reghdfe v2x_polyarchy  L.lagwe_mtech_exf  L.lagwe_lngdpc L.le_total_resources_income_pc if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA10.tex", label bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_redundant)) cttop(OLS) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
reghdfe v2x_polyarchy  L.lagwe_mtech_exf  L.lagwe_lngdpc L.le_total_oil_income_pc L.le_total_resources_income_pc if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA10.tex", label bdec(2) dec(2) nocons nor2 addstat(Countries,  e(df_a_redundant)) cttop(OLS) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.le_total_oil_income_pc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA10.tex", label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf),Countries,  e(df_a_redundant)) cttop(2SLS) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.le_total_resources_income_pc if balance==1 & weu==0 , robust cluster(country) absorb(country year) 
outreg2 using "coercive_imbalance_tables/TableA10.tex", label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf),Countries,  e(df_a_redundant)) cttop(2SLS) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append
ivreghdfe v2x_polyarchy  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.le_total_oil_income_pc L.le_total_resources_income_pc if balance==1 & weu==0 , robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA10.tex", label bdec(2) dec(2) nocons nor2 addstat(Kleibergen-Paap F-statistic, e( rkf),Countries,  e(df_a_redundant)) cttop(2SLS) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc) append

// Table A11: Robustness of 2SLS-results for Bureaucracy 
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.n1_democracy_avg L.n2_democracy_avg if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE,    ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  replace
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.n1_interstatewar L.n2_interstatewar L.n1_civilwar L.n2_civilwar  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) sortvar(L.lagwe_mtech_exf L.lagwe_lngdpc L.n1_democracy_avg L.n2_democracy_avg L.n1_interstatewar L.n2_interstatewar L.n1_civilwar L.n2_civilwar)   append
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.distw1_democracy L.distw1_interstatewar L.distw1_civilwar L.distw1_lngdp  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) append
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.interstatewar_3y L.civilwar_3y  if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  append
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.ally_USA L.ally_Russia if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  append
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.lntrade    if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  append
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc L.lnaid    if balance==1 & weu==0, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex",label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant)) append
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc    if balance==1 & weu==0, robust cluster(country) absorb(country i.year##i.colony_uk i.year##i.colony_fra i.year##i.colony_ger i.year##i.colony_ussr i.year##i.colony_rest )
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  append
ivreghdfe v2x_pubcorr  (L.lagwe_mtech_exf =L.lagwe_mtech_exf_iv_n2) L.lagwe_lngdpc    if balance==1 & weu==0 & colony!=1, robust cluster(country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA11.tex", label bdec(2) dec(2) nocons nor2 addtext(Sample, Excl. WEU & ex-colonies, ColonizerxTime-FE, ) addstat(Kleibergen-Paap F-statistic, e( rkf), Countries, e(df_a_redundant))  append

// Table A12: Mechanisms OLS 
*reghdfe regime_rest L.lagwe_mtech_exf L.lagwe_lngdpc  if balance==1 & weu==0  , vce(cluster country) absorb(country year)
*outreg2 using "coercive_imbalance_tables/TableA12.tex", label bdec(2) dec(2) nocons addstat(Countries,  e(df_a_redundant)) addtext(Sample, Excl. WEU) replace NOT INCLUDED IN REPLICATION SINCE BANKS DATA NOT PUBLICLY AVAILABLE
reghdfe v2csreprss L.lagwe_mtech_exf   L.lagwe_lngdpc  if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA12.tex", label bdec(2) dec(2) nocons addstat(Countries,  e(df_a_redundant)) addtext(Sample, Excl. WEU) replace
reghdfe v2clkill L.lagwe_mtech_exf  L.lagwe_lngdpc  if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA12.tex", bdec(2) dec(2) nocons addstat(Countries,  e(df_a_redundant)) addtext(Sample, Excl. WEU) append
reghdfe lnmilper L.lagwe_mtech_exf L.lagwe_lngdpc L.lnmilex  if balance==1 & weu==0, vce(cluster country) absorb(country year)
outreg2 using "coercive_imbalance_tables/TableA12.tex", bdec(2) dec(2) nocons addstat(Countries,  e(df_a_redundant)) addtext(Sample, Excl. WEU) append

*###############################################################################
*	4 ALL FIGURES IN THE MAIN TEXT
*###############################################################################

cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
// FIGURE 1: Effectiveness of Small Arms Technologies. 
*Source: Zabecki, D.T., 2014. Germany at War: 400 Years of Military History [4 volumes]: 400 Years of Military History. ABC-CLIO.
preserve
clear
set obs 9

gen techname=""
gen effective_range=.
gen rate_of_fire=.

replace techname="Matchlock musket" if _n==1
replace techname="Snaphaunce" if _n==2
replace techname="Flintlock" if _n==3
replace techname="Percussion lock" if _n==4
replace techname="Minié bullet rifle" if _n==5
replace techname="Breechloading rifle" if _n==6
replace techname="Tubular magazine rifle" if _n==7
replace techname="Box magazine rifle" if _n==8
replace techname="Assault rifle" if _n==9

** Data from Zabecki 2014 (see main text). 
** A few corrections for reloading times and expected misfire is made to make the numbers comparable, see the comments below

*a. Effective range (in meters)
replace effective_range=50 if techname=="Matchlock musket"
replace effective_range=50 if techname=="Snaphaunce"
replace effective_range=75 if techname=="Flintlock"
replace effective_range=75 if techname=="Percussion lock"
replace effective_range=300 if techname=="Minié bullet rifle"
replace effective_range=450 if techname=="Breechloading rifle"
replace effective_range=500 if techname=="Tubular magazine rifle"
replace effective_range=500 if techname=="Box magazine rifle"
replace effective_range=400 if techname=="Assault rifle"

*b. Rate of fire (shots/minute)
replace rate_of_fire=0.5 if techname=="Matchlock musket"
replace rate_of_fire=2 if techname=="Snaphaunce"
replace rate_of_fire=3 if techname=="Flintlock" //I have subtracted 1 shot/minute to take misfire into account.
replace rate_of_fire=4 if techname=="Percussion lock"
replace rate_of_fire=4 if techname=="Minié bullet rifle"
replace rate_of_fire=10 if techname=="Breechloading rifle"
replace rate_of_fire=15 if techname=="Tubular magazine rifle"
replace rate_of_fire=20 if techname=="Box magazine rifle" //changed to 20 from 17.5 -> 20 round trench magazines used in WWI, Before that I assume that 10 round magazine could be fired and changed once
replace rate_of_fire=90 if techname=="Assault rifle" //changed to 90 -> practical rate of fire assuming magazine replaced twice in a minute. The rate of fire was otherwise listed as 550 shots/min

*geometric mean
gen simpleeffect=sqrt(effective_range*rate_of_fire)

graph hbar simpleeffect, over(techname, sort(simpleeffect)) ///
ytitle("Geometric mean of range and rate of fire") plotregion(fcolor(white)) graphregion(color(white)) ///
bar(1, color(gs8))

graph export "coercive_imbalance_figures/Figure1.eps", replace
graph export "coercive_imbalance_figures/Figure1.pdf", replace

restore

// FIGURE 2: How Much Are Other Countries Behind Western Europe in Arms Technology and Four Indicators of Modernization 
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear
preserve
drop if year<1850
drop if year>2010

keep if region!="Western Europe and off-shoots" 
keep if democracy!=.

collapse (mean) lagwe_*, by(year)

sort year
twoway line lagwe_mtech year , lcolor(black) lpattern(solid) || ///
line lagwe_lngdpc year , lcolor(gs6) lpattern(solid) || ///
line lagwe_naes year if lagwe_naes<=400, lcolor(gs6) lpattern(longdash)  || ///
line lagwe_ups year , lcolor(gs6) lpattern(dash_dot) || ///
line lagwe_schooling year ,lcolor(gs6) lpattern(dot)  ///
legend(label(1 "Arms technology") label(2 "GDP per capita") label(3 "Industrialization")  label(4 "Urbanization rate") label(5 "Years of schooling")) ///
ytitle("Lag to Western Europe (years)") xtitle("Year") plotregion(fcolor(white)) graphregion(color(white)) scheme(s1color) yline(0)

graph export "coercive_imbalance_figures/Figure2.eps", replace
graph export "coercive_imbalance_figures/Figure2.pdf", replace

restore

// FIGURE 3: Lags in Arms Technology and Economic Development Across Six World Regions
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear

*WEU
twoway (scatter lagwe_mtech_av lagwe_lngdpc_av if year==2010 & region=="Western Europe and off-shoots", mlabel(iso3) mlabcolor(black) mlabposition(12) msymbol(i) mcolor(black) legend(off) xtitle(Lag GDP per capita) ytitle(Lag arms technology) title(WEU and offshoots) ) (lfit lagwe_mtech lagwe_mtech  if year==2010 & region=="Western Europe and off-shoots", lpattern(dash) lcolor(black) range(-50 100) msymbol(iso3) msymbol(i) legend(off) ) , scheme(s1color) yscale(range(-50 0 50 100)) ylabel(-50 0 50 100) name(f1)
*EEU
twoway (scatter lagwe_mtech_av lagwe_lngdpc_av if year==2010 & region=="Eastern Europe and Balkan", mlabel(iso3) mlabcolor(black) mlabposition(12) msymbol(i) mcolor(black) legend(off) xtitle(Lag GDP per capita) ytitle(Lag arms technology) title(Eastern Europe) ) (lfit lagwe_mtech lagwe_mtech  if year==2010 & region=="Eastern Europe and Balkan", lpattern(dash) lcolor(black) range(0 100) msymbol(iso3) msymbol(i) legend(off) ) , scheme(s1color) yscale(range(0 20 40 60 80 100)) ylabel(0 20 40 60 80 100) name(f2)
*LAC
twoway (scatter lagwe_mtech_av lagwe_lngdpc_av if year==2010 & region=="Latin America", mlabel(iso3) mlabcolor(black) mlabposition(12) msymbol(i) mcolor(black) legend(off) xtitle(Lag GDP per capita) ytitle(Lag arms technology) title(Latin America) ) (lfit lagwe_mtech lagwe_mtech  if year==2010 & region=="Latin America", lpattern(dash) lcolor(black) range(0 100) msymbol(iso3) msymbol(i) legend(off) ) , scheme(s1color) yscale(range(0 20 40 60 80 100)) ylabel(0 20 40 60 80 100) name(f3)
*ASIA
twoway (scatter lagwe_mtech_av lagwe_lngdpc_av if year==2010 & region=="Asia and Oceania", mlabel(iso3) mlabcolor(black) mlabposition(12) msymbol(i) mcolor(black) legend(off) xtitle(Lag GDP per capita) ytitle(Lag arms technology) title(Asia) ) (lfit lagwe_mtech lagwe_mtech  if year==2010 & region=="Asia and Oceania", lpattern(dash) lcolor(black) range(0 100) msymbol(iso3) msymbol(i) legend(off) ) , scheme(s1color) yscale(range(0 20 40 60 80 100)) ylabel(0 20 40 60 80 100) name(f4)
*MENA
twoway (scatter lagwe_mtech_av lagwe_lngdpc_av if year==2010 & region=="MENA", mlabel(iso3) mlabcolor(black) mlabposition(12) msymbol(i) mcolor(black) legend(off) xtitle(Lag GDP per capita) ytitle(Lag arms technology) title(MENA) ) (lfit lagwe_mtech lagwe_mtech  if year==2010 & region=="MENA", lpattern(dash) lcolor(black) range(0 100) msymbol(iso3) msymbol(i) legend(off) ) , scheme(s1color) yscale(range(0 20 40 60 80 100)) ylabel(0 20 40 60 80 100) name(f5)
*Africa
twoway (scatter lagwe_mtech_av lagwe_lngdpc_av if year==2010 & region=="Sub-Saharan Africa", mlabel(iso3) mlabcolor(black) mlabposition(12) msymbol(i) mcolor(black) legend(off) xtitle(Lag GDP per capita) ytitle(Lag arms technology) title(Sub-Saharan Africa) ) (lfit lagwe_mtech lagwe_mtech  if year==2010 & region=="Sub-Saharan Africa", lpattern(dash) lcolor(black) range(0 100) msymbol(iso3) msymbol(i) legend(off) ) , scheme(s1color) yscale(range(0 20 40 60 80 100)) ylabel(0 20 40 60 80 100) name(f6)

graph combine f1 f2 f3 f4 f5 f6 ,  graphregion(color(white))

graph export "coercive_imbalance_figures/Figure3.eps", replace
graph export "coercive_imbalance_figures/Figure3.pdf", replace

graph drop *

*Calculate no of countries referenced in text (section 4)
count if lagwe_mtech_av<lagwe_lngdpc_av & year==2010 & weu!=1 & independent=="yes"  
count if lagwe_mtech_av>lagwe_lngdpc_av & year==2010 & weu!=1 & independent=="yes" 

// FIGURE 4: Average Adoption Lags for Arms and Civilian Technologies
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear


local categories "s a r t m h"
local stechs "1 2 3 4 5 6 7 8"
local atechs "1 2 3 4 5"
local rtechs "1 2 3 4 5 6"
local ttechs "1 2 3 4 5"
local mtechs "1 2"
local htechs "1 2"

//generate adoption lag if existed when tech invented
foreach x of local categories {
foreach y of local `x'techs {
gen temp1=adoptionyear`x'`y'
egen invented`x'`y'=min(temp1)
gen temp2=1 if independent=="yes" & year==invented`x'`y'
replace temp2=1 if independent=="yes" & year==invented`x'`y'+5
egen existed_at_invetion=mean(temp2), by(country)
gen adoptionlag`x'`y'=adoptionyear`x'`y'-invented`x'`y' if adoptionyear`x'`y'<3000  & existed_at_invetion==1
drop temp* existed_at_invetion
}
}

rename adoptionyears* adoptionyear1*
rename adoptionyeara* adoptionyear2*
rename adoptionyearr* adoptionyear3*
rename adoptionyeart* adoptionyear4*
rename adoptionyearm* adoptionyear5*
rename adoptionyearh* adoptionyear6*

rename *lags* *lag1*
rename *laga* *lag2*
rename *lagr* *lag3*
rename *lagt* *lag4*
rename *lagm* *lag5*
rename *lagh* *lag6*

rename inventeds* invented1*
rename inventeda* invented2*
rename inventedr* invented3*
rename inventedt* invented4*
rename inventedm* invented5*
rename inventedh* invented6*

keep if year==2000
keep adoptionlag* adoptionyear* invented*  country region

reshape long adoptionlag adoptionyear invented, i(country) j(tech)



append using  "coercive_imbalance_raw\comin_adoption_lags.dta"

replace country="Bolivia, Plurinational State of" if country=="Bolivia"
replace country="Bosnia and Herzegovina" if country=="Bosnia-Herzegovina"
replace country="Cote d'Ivoire" if country=="Cote D'Ivoire"
replace country="Czech Republic" if country=="Czechoslovakia"
replace country="Iran, Islamic Republic of" if country=="Iran"
replace country="Cote d'Ivoire" if country=="Ivory Coast"
replace country="Lao People's Democratic Republic" if country=="Laos"
replace country="Congo" if country=="Republic of the Congo"
replace country="Russian Federation" if country=="Russia"
replace country="Slovakia" if country=="Slovak Republic"
replace country="Korea, Republic of" if country=="South Korea"
replace country="Syrian Arab Republic" if country=="Syria"
replace country="Taiwan, Province of China" if country=="Taiwan"
replace country="Tanzania, United Republic of" if country=="Tanzania"
replace country="Venezuela, Bolivarian Republic of" if country=="Venezuala"
replace country="Viet nam" if country=="Vietnam"


///create coercive adoption balanced to comin
gen temp1=1 if tech>900 & adoptionlag!=. & invented<1910
gen temp2=1 if tech>900 & adoptionlag!=. & invented>=1910 & invented<1940
gen temp3=1 if tech>900 & adoptionlag!=. & invented>=1940
egen sample1=sum(temp1), by(country)
egen sample2=sum(temp2), by(country)
egen sample3=sum(temp3), by(country)
gen comin_sample=0
replace comin_sample=1 if tech>900
replace comin_sample=1 if sample1>0 & invented<1910
replace comin_sample=1 if sample2>0 & invented>=1910 & invented<1940
replace comin_sample=1 if sample3>0 & invented>=1940

gen comin_sample_adoptionlag=.
replace comin_sample_adoptionlag=adoptionlag if comin_sample==1 & adoptionyear<=2002

gen obs_adoption=1 if adoptionlag!=.

gen adoptionlag_nonwe_comin=adoptionlag if region!="Western Europe and off-shoots" & comin_sample==1  
replace adoptionlag_nonwe_comin=adoptionlag if region!="Western Europe and off-shoots" & comin_sample==1 & adoptionlag!=. 
gen coercive=1
replace coercive=0 if tech>=900

//Collapse
collapse (mean) adoptionlag*  invented (sum) obs*, by(tech)

drop if tech==919 | tech==920 | tech==921 | tech==922 | tech==925 | tech==602 |  tech==405

drop if invented<1800 | invented==.
gen military=1 if tech<900
sort military invented
gen temp=_n
replace temp=temp-24 if military==.
tostring temp, force replace
gen tech_fig="m" + temp if military==1
replace tech_fig="c" + temp if military==.

preserve


set scheme plotplainblind 
twoway scatter adoptionlag_nonwe_comin invented if tech<900 & invented>1810, mcolor(black) mlabel(tech_fig) mlabcolor(black) msymbol(circle) || ///
scatter adoptionlag_nonwe_comin invented if tech>900 & invented>1810, mcolor(gs8) mlabel(tech_fig)  msymbol(circle) mlabcolor(gs8)  ///
legend(label(1 "Military") label(2 "Civilian")  ) plotregion(fcolor(white)) graphregion(color(white)) ///
xtitle("Year of first use anywhere") ytitle("Average adoption lag") ylabel(0(20) 80) yscale(range(0 80)) 

graph export "coercive_imbalance_figures/Figure4.eps", replace
graph export "coercive_imbalance_figures/Figure4.pdf", replace

restore

// FIGURE 5: Diffusion of Steam and Motor Ships for Military and Civilian Purposes
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_raw\ships.dta", clear


destring ship*, replace force
drop if year<1800
drop if year>1950

gen temp=year if ship_steam_navy!=.
egen firstobs_steam=min(temp), by(country)
drop temp
gen temp=year if ship_sail_navy!=.
egen firstobs_sail=min(temp), by(country)
drop temp
drop if firstobs_steam>1880

replace ship_motor=0 if year<1910
replace ship_motor_navy=0 if year<1910
replace ship_sail_navy=0  if ship_sail_navy+ship_steam_navy+ship_motor_navy==0 
replace ship_steam_navy=0  if ship_sail_navy+ship_steam_navy+ship_motor_navy==0 
replace ship_motor_navy=0  if ship_sail_navy+ship_steam_navy+ship_motor_navy==0 
replace ship_steammotor=ship_steam+ship_motor if ship_steam!=0 & ship_motor!=0
replace ship_steammotor=ship_steam if ship_steammotor==.
replace ship_steammotor=ship_motor if ship_steammotor==.
replace shipton_steammotor=shipton_steam+shipton_motor if shipton_steam!=0 & shipton_motor!=0
replace shipton_steammotor=shipton_steam if shipton_steammotor==.
replace shipton_steammotor=shipton_motor if shipton_steammotor==.

egen country_id=group(country)
xtset country_id year

foreach x of varlist ship* {
ipolate `x' year, by(country) gen(temp)
replace `x'=temp
drop temp
}

gen tradefleet=ship_sail+ship_steammotor
gen tradeton=shipton_sail+shipton_steammotor
gen navy=ship_sail_navy+ship_steam_navy+ship_motor_navy
gen trade_steammotor=ship_steammotor/tradefleet
gen tradeton_steammotor=shipton_steammotor/tradeton
gen navy_sail=ship_sail_navy/navy
gen navy_steammotor=1-navy_sail

replace navy_steammotor=0 if year<1820
replace navy_sail=1 if year<1820
replace navy_steammotor=1 if year>1900
replace navy_sail=0 if year>1900
ipolate navy_steammotor year, gen(temp) by(country)
replace navy_steammotor=temp
drop temp
ipolate navy_sail year, gen(temp) by(country)
replace navy_sail=temp
drop temp

replace shipton_steammotor=. if ship_steammotor==.
replace ship_steammotor=. if shipton_steammotor==.

collapse (mean) trade* navy* ship*, by(year)

gen tonnage_sail=shipton_sail/ship_sail
gen tonnage_steam=shipton_steammotor/ship_steammotor
gen navyton_sail=navy_sail*tonnage_sail/(navy_sail*tonnage_sail+navy_steammotor*tonnage_steam)
gen navyton_steammotor=1-navyton_sail

twoway line navy_steammotor year, lcolor(black)  ///
|| line trade_steammotor year, lcolor(gs8)  ///
|| line navyton_steammotor year, lcolor(black)  lpattern(dash) ///
|| line tradeton_steammotor year, lcolor(gs8)  lpattern(dash) ///
plotregion(fcolor(white)) graphregion(color(white)) ///
xtitle("Year") ytitle("Share of ships or tonnage") ///
legend(label(1 "Navy, % of ships")  label(2 "Merchant ships, % of ships")  label(3 "Navy, % of tonnage (est)") label(4 "Merchant ships, % of tonnage") pos(6)) scheme(s1color)

graph export "coercive_imbalance_figures/Figure5.eps", replace
graph export "coercive_imbalance_figures/Figure5.pdf", replace

// FIGURE 6: Western Europe and the Former Colonies
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear

preserve
keep if year>=1950 & year<=2010
gen temp=year  if independent!="yes" & year<2010
egen yearindp=max(temp), by(iso)
replace yearindp=yearindp+1
gen ysi=year-yearindp
drop temp

gen decade_indpendence=floor(yearindp/5)*5

keep if decade_indpendence<=1975 | decade_indpendence==.

drop if decade_indpendence==. & weu==0

egen tpopavg=mean(tpop), by(country)

drop if tpopavg<1000
bysort yearindp: tab country
bysort decade_indpendence: tab country

collapse (mean) mtech mtech_exf lagwe_mtech_exf lngdpc, by(decade_indpendence year)

replace mtech=. if decade_indpendence==1955 & year<1960
replace mtech=. if decade_indpendence==1960 & year<1965
replace mtech=. if decade_indpendence==1965 & year<1970
replace mtech=. if decade_indpendence==1970 & year<1975
replace mtech=. if decade_indpendence==1975 & year<1980

replace lngdpc=. if decade_indpendence==1955 & year<1960
replace lngdpc=. if decade_indpendence==1960 & year<1965
replace lngdpc=. if decade_indpendence==1965 & year<1970
replace lngdpc=. if decade_indpendence==1970 & year<1975
replace lngdpc=. if decade_indpendence==1975 & year<1980

drop if year<1960

twoway line mtech year if decade_indpendence==., lcolor(black) lpattern(solid)  || line mtech year if decade_indpendence==1955, lcolor(gs6) lpattern(longdash) || line mtech year if decade_indpendence==1960, lcolor(gs6) lpattern(dash_dot) || line mtech year if decade_indpendence==1965, lcolor(gs6) lpattern(dot) ///
legend(label(1 "Western Europe") label(2 "Independent 1955-59") label(3 "Independent 1960-64")  label(4 "Independent 1964-69") rows(2)) ///
ytitle("Number of military techologies") xtitle("Year") plotregion(fcolor(white)) graphregion(color(white)) title("Panel A: Military technology")  
graph save Graph "panelA", replace

twoway line lngdpc year if decade_indpendence==., lcolor(black) lpattern(solid)  || line lngdpc year if decade_indpendence==1955, lcolor(gs6) lpattern(longdash) || line lngdpc year if decade_indpendence==1960, lcolor(gs6) lpattern(dash_dot) || line lngdpc year if decade_indpendence==1965, lcolor(gs6) lpattern(dot) ///
legend(label(1 "Western Europe") label(2 "Independent 1955-59") label(3 "Independent 1960-64")  label(4 "Independent 1964-69") rows(2)) ///
ytitle("Log GDP per capita") xtitle("Year") plotregion(fcolor(white)) graphregion(color(white)) title("Panel B: GDP per capita")  
graph save Graph "panelB", replace


grc1leg2 panelA.gph panelB.gph, iscale(1) altshrink rows(1) cols(2) legendfrom(panelA.gph) graphregion(color(white))
graph export "coercive_imbalance_figures/Figure6.eps", replace
graph export "coercive_imbalance_figures/Figure6.pdf", replace
erase panelA.gph 
erase panelB.gph

restore

*###############################################################################
*	5 ALL FIGURES IN THE ONLINE APPENDIX
*###############################################################################

// Appendix FIGURE A1: How Much Are Other Countries Behind Western Europe in Arms Technology and Four Indicators of Modernization (balanced sample)
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear

preserve
drop if year<1850
drop if year>2010

*gen balance non-we sample
gen temp=1 if democracy!=.
egen yrs_indep=sum(temp), by(iso3)
drop temp

gen nonwe_bal=0
replace nonwe_bal=1 if yrs_indep>160 & yrs_indep!=. & region!="Western Europe and off-shoots"

keep if nonwe_bal==1

tab country

collapse (mean) lagwe_*, by(year)

sort year
twoway line lagwe_mtech year , lcolor(black) lpattern(solid) || ///
line lagwe_lngdpc year , lcolor(gs6) lpattern(solid) || ///
line lagwe_naes year if lagwe_naes<=400, lcolor(gs6) lpattern(longdash)  || ///
line lagwe_ups year , lcolor(gs6) lpattern(dash_dot) || ///
line lagwe_schooling year ,lcolor(gs6) lpattern(dot)  ///
legend(label(1 "Arms technology") label(2 "GDP per capita") label(3 "Industrialization")  label(4 "Urbanization") label(5 "Schooling")) ///
ytitle("Lag to Western Europe (years)") xtitle("Year") plotregion(fcolor(white)) graphregion(color(white)) scheme(s1color) yline(0)

graph export "coercive_imbalance_figures/FigureA1.eps", replace
graph export "coercive_imbalance_figures/FigureA1.pdf", replace

restore



// Appendix FIGURE A2: Modernization and Arms Technologies Across Regions
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear

rename adoptionyears* adoptionyear1*
rename adoptionyeara* adoptionyear2*
rename adoptionyearr* adoptionyear3*
rename adoptionyeart* adoptionyear4*
rename adoptionyearm* adoptionyear5*
rename adoptionyearh* adoptionyear6*

rename firstuses* firstuse1*
rename firstusea* firstuse2*
rename firstuser* firstuse3*
rename firstuset* firstuse4*
rename firstusem* firstuse5*
rename firstuseh* firstuse6*

drop *_use
drop if year<1700

 
reshape long adoptionyear firstuse, i(year region* country naes ups lngdp iso3 schooling) j(tech)
egen invented=min(adoptionyear), by(tech) 

drop if invented<=1700


*ordering
gen temp=invented+tech/1000
sort temp
egen techorder=group(temp)
drop temp
sort country year techorder

***Generate regional averages

*frontier -> update
egen temp=mean(lngdp) if country=="France" | country=="United Kingdom" | country=="Germany", by(year)
replace temp=. if invented!=year
egen lngdp_adopt_frontier=mean(temp), by(tech)
drop temp
egen temp=mean(naes) if country=="France" | country=="United Kingdom" | country=="Germany", by(year)
replace temp=. if invented!=year
egen naes_adopt_frontier=mean(temp), by(tech)
drop temp
egen temp=mean(ups) if country=="France" | country=="United Kingdom" | country=="Germany", by(year)
replace temp=. if invented!=year
egen ups_adopt_frontier=mean(temp), by(tech)
drop temp

*adoption
egen adoption_region=mean(adoptionyear), by(tech region)
gen temp=naes if year==adoptionyear 
egen naes_adopt_region=mean(temp), by(region tech)
replace temp=.
replace temp=ups if year==adoptionyear  
egen ups_adopt_region=mean(temp), by(region tech)
replace temp=.
replace temp=lngdpc if year==adoptionyear  
egen lngdp_adopt_region=mean(temp), by(region tech)
replace temp=.
replace temp=schooling if year==adoptionyear  
egen edu_adopt_region=mean(temp), by(region tech)

sort techorder

*combined modernization figures, adoption (grc1leg2 needs to be installed)
twoway line lngdp_adopt_region techorder if country=="France" & year==2000, lcolor(black) lwidth(medthick) || ///
line lngdp_adopt_region techorder if country=="Poland" & year==2000, lcolor(gs10) lwidth(medthick) || ///
line lngdp_adopt_region techorder if country=="Turkey" & year==2000, lcolor(gs6) lwidth(medthick) || ///
line lngdp_adopt_region techorder if country=="China" & year==2000, lcolor(gs6) lpattern(dash) lwidth(medthick) || ///
line lngdp_adopt_region techorder if country=="Mali" & year==2000, lcolor(gs10) lpattern(dash) lwidth(medthick) || ///
line lngdp_adopt_region techorder if country=="Brazil" & year==2000, lcolor(black) lpattern(dash) lwidth(medthick)  /// 
legend(label(1 "W Europe and off-shoots") label(2 "Eastern Europe") label(3 "MENA") ///
label(4 "Asia and Oceania") label(5 "Sub-Saharan Africa") label(6 "Latin America") ) ///
plotregion(fcolor(white)) graphregion(color(white)) ///
xtitle("Technology no." , size(small)) xlabel(, labsize(small)) ytitle("Log GDP per capita") ylabel(, labsize(small)) ///
name(panela, replace) nodraw title("Panel A: GDP per capita", size(small) color(black) justification(center))

twoway line edu_adopt_region techorder if country=="France" & year==2000, lcolor(black) lwidth(medthick) || ///
line edu_adopt_region techorder if country=="Poland" & year==2000, lcolor(gs10) lwidth(medthick) || ///
line edu_adopt_region techorder if country=="Turkey" & year==2000, lcolor(gs6) lwidth(medthick) || ///
line edu_adopt_region techorder if country=="China" & year==2000, lcolor(gs6) lpattern(dash) lwidth(medthick) || ///
line edu_adopt_region techorder if country=="Mali" & year==2000, lcolor(gs10) lpattern(dash) lwidth(medthick) || ///
line edu_adopt_region techorder if country=="Brazil" & year==2000, lcolor(black) lpattern(dash) lwidth(medthick)  /// 
legend(label(1 "W Europe and off-shoots") label(2 "Eastern Europe") label(3 "MENA") ///
label(4 "Asia and Oceania") label(5 "Sub-Saharan Africa") label(6 "Latin America") ) ///
plotregion(fcolor(white)) graphregion(color(white)) ///
xtitle("Technology no." , size(small)) xlabel(, labsize(small)) ytitle("Average years of schooling") ylabel(, labsize(small)) ///
name(panelb, replace) nodraw title("Panel B: Schooling", size(small) color(black) justification(center))

twoway line naes_adopt_region techorder if country=="France" & year==2000, lcolor(black) lwidth(medthick) || ///
line naes_adopt_region techorder if country=="Poland" & year==2000, lcolor(gs10) lwidth(medthick) || ///
line naes_adopt_region techorder if country=="Turkey" & year==2000, lcolor(gs6) lwidth(medthick) || ///
line naes_adopt_region techorder if country=="China" & year==2000, lcolor(gs6) lpattern(dash) lwidth(medthick) || ///
line naes_adopt_region techorder if country=="Mali" & year==2000, lcolor(gs10) lpattern(dash) lwidth(medthick) || ///
line naes_adopt_region techorder if country=="Brazil" & year==2000, lcolor(black) lpattern(dash) lwidth(medthick)  /// 
legend(label(1 "W Europe and off-shoots") label(2 "Eastern Europe") label(3 "MENA") ///
label(4 "Asia and Oceania") label(5 "Sub-Saharan Africa") label(6 "Latin America") ) ///
plotregion(fcolor(white)) graphregion(color(white)) ///
xtitle("Technology no." , size(small)) xlabel(, labsize(small)) ytitle("Nonagricultural employment") ylabel(, labsize(small)) ///
name(panelc, replace) nodraw title("Panel C: Industrialization", size(small) color(black) justification(center))

twoway line ups_adopt_region techorder if country=="France" & year==2000, lcolor(black) lwidth(medthick) || ///
line ups_adopt_region techorder if country=="Poland" & year==2000, lcolor(gs10) lwidth(medthick) || ///
line ups_adopt_region techorder if country=="Turkey" & year==2000, lcolor(gs6) lwidth(medthick) || ///
line ups_adopt_region techorder if country=="China" & year==2000, lcolor(gs6) lpattern(dash) lwidth(medthick) || ///
line ups_adopt_region techorder if country=="Mali" & year==2000, lcolor(gs10) lpattern(dash) lwidth(medthick) || ///
line ups_adopt_region techorder if country=="Brazil" & year==2000, lcolor(black) lpattern(dash) lwidth(medthick)  /// 
legend(label(1 "W Europe and off-shoots") label(2 "Eastern Europe") label(3 "MENA") ///
label(4 "Asia and Oceania") label(5 "Sub-Saharan Africa") label(6 "Latin America") ) ///
plotregion(fcolor(white)) graphregion(color(white)) ///
xtitle("Technology no." , size(small)) xlabel(, labsize(small)) ytitle("Urbanization rate") ylabel(, labsize(small)) ///
name(paneld, replace) nodraw title("Panel D: Urbanization", size(small) color(black) justification(center))

grc1leg2 panela panelb panelc paneld, ///
cols(2) plotregion(fcolor(white)) graphregion(color(white)) scheme(s1color) ///
legendfrom(panela) lsize(small) 

graph export "coercive_imbalance_figures/FigureA2.eps", replace
graph export "coercive_imbalance_figures/FigureA2.pdf", replace

// Appendix FIGURE A3: Arms Technology and Administrative Technology
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear

by iso3 (year), sort: gen byte first_census = sum(census) == 1  & sum(census[_n - 1]) == 0 
by iso3 (year), sort: gen byte first_yearbook = sum( yearbook_published ) == 1  & sum( yearbook_published [_n - 1]) == 0
egen firstyear_census = total(year * (first_census == 1)), by(iso3)
egen firstyear_yearbook = total(year * (first_yearbook == 1)), by(iso3)
drop census
drop yearbook_published
rename firstyear_census census
replace census=. if census==0
rename firstyear_yearbook yearbook
replace yearbook=. if yearbook==0
drop first_census
drop first_yearbook

replace University=max(1300,University) if University<1300


gen ones=1
egen region_no=group(region)

rename census Census
rename yearbook Yearbook

replace region="W. Europe + off-shoots" if region=="Western Europe and off-shoots"
replace region="Eastern Europe" if region=="Eastern Europe and Balkan"

foreach x of varlist Census Yearbook Diplo* University   { 
preserve
drop if year!=`x'
collapse (sum) ones (mean) mtech region_no, by(region) 
list region ones
drop if ones<3
graph bar mtech, horizontal over(region, sort(1) ) yscale(range(0 22)) ytitle("") ///
plotregion(fcolor(white)) graphregion(color(white))  ylabel(, labsize(small)) ///
name(`x', replace) title("`x'", color(black) justification(center)) legend(label(1 "Military technologies in use"))
restore

}

grc1leg2 Census Yearbook Diplomacy University, cols(2) plotregion(color(white)) graphregion(color(white)) xcommon ycommon 

graph export "coercive_imbalance_figures/FigureA3.eps", replace
graph export "coercive_imbalance_figures/FigureA3.pdf", replace

*Calculate averages referenced in section 4 text
encode region, gen(regionno)
mean Census if Census!=. & year==2010, over(regionno)
mean Yearbook if Yearbook!=. & year==2010, over(regionno)


// Appendix FIGURE A4: Examples of Weighted Adoption Rates and the Instrument
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_final\ci_main_jop.dta", clear

preserve
gen tech_1=m2_iv_n2
gen tech_2=r3_iv_n2

drop if year<1850 & year>2010

*Panel A
twoway line tech_1 year if country=="Turkey" & year>1850 & year<2010, lcolor(black) ///
|| line tech_1 year if  country=="Brazil" & year>1850 & year<2010, lcolor(gs5)  ///
|| line tech_1 year if  country=="Thailand" & year>1850 & year<2010, lcolor(gs10) ///
|| line tech_2 year if country=="Turkey" & year>1850 & year<2010, lcolor(black)   ///
|| line tech_2 year if  country=="Brazil" & year>1850 & year<2010, lcolor(gs5)   ///
|| line tech_2 year if  country=="Thailand" & year>1850 & year<2010, lcolor(gs10)   ///
plotregion(fcolor(white)) graphregion(color(white)) scheme(s1color) ///
legend(order(1 "Turkey" 2 "Brazil" 3 "Thailand") rows(1) ) ///
ytitle("Weighted adoption rate") xtitle("Year") title(Panel A: Weighted adoption rates) ///
text(0.9 1885  "Automatic" "machine gun") text(0.5 1980  "First generation" "jet fighter")  name(panela, replace)

*Panel B
twoway line mtech_exf year if country=="Turkey" & year>1850 & year<2010, lcolor(gs10) || line mtech_exf_iv_n2 year if country=="Turkey" & year>1850 & year<2010, lcolor(black) ///
plotregion(fcolor(white)) graphregion(color(white)) scheme(s1color) ///
legend(label(1 "Actual") label(2 "Instrument")  region(col(white))) ytitle("Military technology index") xtitle("Year") name(panelb, replace) title(Panel B: Instrument Turkey)

resizecombine panela panelb, plotregion(fcolor(white)) graphregion(color(white)) xsize(12cm) ysize(16cm) cols(1)

graph export "coercive_imbalance_figures/FigureA4.eps", replace
graph export "coercive_imbalance_figures/FigureA4.pdf", replace

restore


// Appendix FIGURE A5: Lower Cost per Effective Unit of Coercion
cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance\Replication
use "coercive_imbalance_raw\prices_jop.dta", clear

replace priceusdollar=price if currency=="US DOLLAR" & priceusdollar==.
drop if tech=="uncertain" | tech=="other" | tech==""

merge m:1 year using "coercive_imbalance_raw\cpi.dta"
drop if _merge==2
drop _merge

sort tech year
egen techno=group(tech)

gen category=substr(tech,1,1)
replace category="m" if tech=="f11" | tech=="f12"
replace category="h" if tech=="r08" | tech=="r09"

gen originalprice=price

replace price=priceusdollar/usdgbp/uk_cpi*100
replace price=pricepounds/uk_cpi*100 if price==.

drop if price==.

drop if transactiontype=="Illicit"
drop if transactiontype=="Used"
drop if transactiontype=="Discounted"
drop if techname=="uncertain"


egen firstyear=min(year), by(tech)

egen meanprice=mean(price), by(tech)
gen lnprice=ln(price)

gen bundle=0
replace bundle=1 if transactiontype=="Bundled"
quietly: xi: reg price bundle i.tech if category=="a"
gen price_unbundled=price-_b[bundle]*bundle

gen price_bundle=price if bundle==1
gen price_nobundle=price if bundle==0

preserve 

local new = _N + 2
set obs `new'
replace techname="Matchlock musket" if _n==`new'-1
replace tech="f03" if _n==`new'-1
replace techname="Snaphaunce" if _n==`new'
replace tech="f04" if _n==`new'
replace category="f" if _n>`new'-2
replace buyer="US Government" if _n>`new'-2
sort tech year


**Generate Panel A: Price of Small Arms
graph hbar price if category=="f" & buyer=="US Government", over(techname, sort(firstyear)) ///
ytitle("Price (2010 USD)") plotregion(fcolor(white)) graphregion(color(white)) title(Price of Small Arms) ///
bar(1, color(gs8))   text(5 95 "N/a", place(e))  text(5 84 "N/a", place(e))
graph save Graph "panelA", replace

**Generate Panel B: Price of Artillery
graph hbar price if category=="a" & bundle==0, over(techname, sort(techno)  ) ///
ytitle("Price (2010 USD)") plotregion(fcolor(white)) graphregion(color(white)) ///
bar(1, color(gs8)) title(Price of Artillery)
graph save Graph "panelB", replace
restore

**Index construction firearms
*cd "/Users/ngb815/Dropbox/Coercive_tech/stata/coercive_imbalance
clear
set obs 14

gen techname=""

replace techname="Matchlock musket" if _n==1
replace techname="Snaphaunce" if _n==2
replace techname="Flintlock" if _n==3
replace techname="Percussion lock" if _n==4
replace techname="Minié bullet rifle" if _n==5
replace techname="Breechloading rifle" if _n==6
replace techname="Tubular magazine rifle" if _n==7
replace techname="Box magazine rifle" if _n==8
replace techname="Assault rifle" if _n==9
replace techname="Field gun" if _n==10
replace techname="Rifled artillery" if _n==11
replace techname="Steel tubes" if _n==12
replace techname="Breechloading" if _n==13
replace techname="Recoil mechanism" if _n==14

** Effectiveness of Small Arms Technologies // Source here is: Zabecki, D.T., 2014. Germany at War: 400 Years of Military History [4 volumes]. ABC-CLIO.
*a. Range
gen effective_range=50 if techname=="Matchlock musket"
label variable effective_range "Effective firearms range in meters"
replace effective_range=50 if techname=="Matchlock musket"
replace effective_range=50 if techname=="Snaphaunce"
replace effective_range=75 if techname=="Flintlock"
replace effective_range=75 if techname=="Percussion lock"
replace effective_range=300 if techname=="Minié bullet rifle"
replace effective_range=450 if techname=="Breechloading rifle"
replace effective_range=500 if techname=="Tubular magazine rifle"
replace effective_range=500 if techname=="Box magazine rifle"
replace effective_range=400 if techname=="Assault rifle"
*b. Rate of fire
gen rate_of_fire=0.5 if techname=="Matchlock musket"
label variable rate_of_fire "Max rate of fire firearms (shots/minute)"
replace rate_of_fire=2 if techname=="Snaphaunce"
replace rate_of_fire=3 if techname=="Flintlock" //I have subtracted 1 shot/minute to take misfire into account.
replace rate_of_fire=4 if techname=="Percussion lock"
replace rate_of_fire=4 if techname=="Minié bullet rifle"
replace rate_of_fire=10 if techname=="Breechloading rifle"
replace rate_of_fire=15 if techname=="Tubular magazine rifle"
replace rate_of_fire=20 if techname=="Box magazine rifle" //changed to 20 from 17.5 -> 20 round trench magazines used in WWI, Before that I assume that 10 round magazine could be fired and changed once
replace rate_of_fire=90 if techname=="Assault rifle" //changed to 90 -> practical rate of fire assuming magazine replaced twice in a minute. The rate of fire was otherwise listed as 550 shots/min

**Index construction artillery
*a. Range (shots per minute
replace effective_range=(900+1480)/2 if techname=="Field gun" //source: https://en.wikipedia.org/wiki/Canon_de_12_Gribeauval AND https://en.wikipedia.org/wiki/Canon_obusier_de_12
replace effective_range=2800 if techname=="Rifled artillery" //source: https://en.wikipedia.org/wiki/La_Hitte_system AND http://francoprussianwar.com/armies.htm
replace effective_range=3800 if techname=="Steel tubes" //source: Source: Bruce I- Gudmundsson "On Artillery"https://www.questia.com/read/28495535/on-artillery
replace effective_range=(3000+3000+5000)/3 if techname=="Breechloading"
replace effective_range=(7500+8500)/2 if techname=="Recoil mechanism" // Sources: https://en.wikipedia.org/wiki/76_mm_gun_M1900 + https://en.wikipedia.org/wiki/Canon_de_75_mod%C3%A8le_1897 
*b. Rate of fire
replace rate_of_fire=1 if techname=="Field gun"
replace rate_of_fire= 1 if techname=="Rifled artillery"
replace rate_of_fire=2 if techname=="Steel tubes" // sources say 2-3. Conservatively set to 2.
replace rate_of_fire=2 if  techname=="Breechloading" // https://en.wikipedia.org/wiki/De_Bange_90_mm_cannon
replace rate_of_fire=8 if techname=="Recoil mechanism" //average of sustained and burst. Could in theory fire three times as often

gen simpleeffect=sqrt(effective_range*rate_of_fire)

gen category=""
replace category="f" if _n<10
replace category="a" if _n>9

graph hbar simpleeffect if category=="f", over(techname, sort(simpleeffect)) ///
ytitle("Geometric mean of range and rate of fire") plotregion(fcolor(white)) graphregion(color(white)) ///
bar(1, color(gs8)) title(Effectiveness of Small Arms)
graph save Graph "panelC", replace

graph hbar simpleeffect if category=="a", over(techname, sort(simpleeffect)) ///
ytitle("Geometric mean of range and rate of fire") plotregion(fcolor(white)) graphregion(color(white)) ///
bar(1, color(gs8)) title(Effectiveness of Artillery)
graph save Graph "panelD", replace

graph combine "panelA.gph" "panelB.gph" "panelC.gph" "panelD.gph", plotregion(fcolor(white)) graphregion(color(white))

graph export "coercive_imbalance_figures/FigureA5.eps", replace
graph export "coercive_imbalance_figures/FigureA5.pdf", replace


erase panelA.gph 
erase panelB.gph
erase panelC.gph 
erase panelD.gph

log off
log close
